﻿using Microsoft.AspNetCore.Hosting;
using Simple.Entity.Entity;
using Simple.Entity.View;
using Simple.IRepository;
using Simple.Tools;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Simple.Repository
/// <summary>
/// 版 本 钢易智企2.0 V 2.0.0 钢易智企2.0
/// Copyright (c) 2023 杭州钢易科技有限公司
/// 创建人：曾东明
/// 日 期：2024
/// 描 述：
/// </summary>
{
	public class MenuRepository : WholeRepository<SysMenuEntity, long>, IMenuRepository
	{
		public MenuRepository()
		{

		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="matchCondition"></param>
		/// <returns></returns>
		public ISugarQueryable<MenuView> Query(Action<ISugarQueryable<SysMenuEntity>> matchCondition)
		{
			SimpleCheck.IsNullThrowException(matchCondition);

			var query=dbClient.Queryable<SysMenuEntity>();

			matchCondition.Invoke(query);

			return query.Select(m=>new MenuView
			{
				ID=m.Id.ToString(),
				Soft=m.Soft,
				IsChild=m.IsChild,
				MenuIcon=m.MenuIcon,
				MenuName=m.MenuName,
				ParentID=m.ParentId.ToString(),
				MenuPath=m.MenuPath,
				MenuType=m.MenuType,
			});
		}
	}
}
